﻿using System;
using System.Collections.Generic;

using Rubik.Common;

namespace Rubik.Tester
{
    public class RubikTestManager
    {
        private const int NumberOfTest = 10;

        /// <summary>
        /// Tests the specified cube serializer.
        /// </summary>
        /// <param name="activator">The activator.</param>
        /// <returns>The test results</returns>
        public IEnumerable<SolutionTestResult> Test(RubikSolutionActivator activator)
        {
            IList<SolutionTestResult> results = new List<SolutionTestResult>();

            Cube cube = new Cube();
            cube.Initialize();

            for (int i = 0; i < NumberOfTest; i++)
            {
                RubikSolutionTester tester = new RubikSolutionTester();

                SolutionTestResult testResult = tester.Test(activator, cube);
                results.Add(testResult);

                // the first test is performed for default cube state. The following
                // tests are performed using random state.
                CubeGenerator.Generate(cube);
            }
            return results;
        }
    }
}
